 <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>SplitContainer Demo</title>
     <style type="text/css">
            @import "../dojo/dojo-release-1.0.0/dijit/themes/tundra/tundra.css";
            @import "../dojo/dojo-release-1.0.0/dojo/resources/dojo.css";
            @import "../dojo/dojo-release-1.0.0/dojox/grid/_grid/tundraGrid.css";
            @import "../dojo/dojo-release-1.0.0/dojox/grid/_grid/Grid.css";
			@import "../dojo/dojo-release-1.0.0/dojox/layout/tests/_expando.css";
			@import "../js/wlProject.css";
			@import "../js/dijitTests.css";
   .titleclass{font-size:12pt;font-weight:bolder;text-align:center}
  #grid { 
			
			width: 40em;
			height: 50em;
		}
			
			
        </style>
        <script type="text/javascript" src="../dojo/dojo-release-1.0.0/dojo/dojo.js"
                djConfig="parseOnLoad: true, isDebug: true,locale: 'zh-cn', extraLocale: ['zh-TW', 'fr']"></script>
 <script>
    
            dojo.require("dojo.data.ItemFileWriteStore");
			dojo.require("dijit.layout.BorderContainer");
            dojo.require("dojox.layout.ExpandoPane");
			dojo.require("dojox.layout.FloatingPane");
            dojo.require("dijit.layout.ContentPane");
            dojo.require("dijit.Tree");
            dojo.require("dojo.parser");
            dojo.require("dijit._tree.dndSource");
            dojo.require("dijit.layout.TabContainer");
            dojo.require("dijit.form.Button");
            dojo.require("dojox.grid.Grid");
            dojo.require("dojox.grid._data.model");
            dojo.require("dojo.i18n");
            dojo.require("dojox.validate._base");
            dojo.require("dijit.form.ValidationTextBox");
            dojo.require("dijit.form.TextBox");
            dojo.require("dijit.form.FilteringSelect");
            dojo.require("dojox.grid._data.dijitEditors");
			dojo.registerModulePath("mydojo", "../../../js/mydojo");
            dojo.require("mydojo.FilteringSelect");
            dojo.require("mydojo.ValidationTextBox");
            dojo.require("mydojo.NumberTextBox");
            </script>
        
<script type="text/javascript" src="../js/soapclient.js"></script>
<script type="text/javascript" src="../js/wlProject.js"></script>
<script type="text/javascript" src="../js/place.js"></script>
<script type="text/javascript" src="../js/path.js"></script>

<script type="text/javascript" >


         var data =new Array();
         var areadata =new Array();
         var placedata = [[false,"","","",""]];
         var querydata = new Array();
         var citydata = new Array();
         var cityareadata = new Array();
         var poptarts ={ label:'name',identifier:'eId',items:data};
		 var url = "http://localhost:8080/logistics-ws/services/BasicManageService";
		
         var popStore = new dojo.data.ItemFileWriteStore({data: poptarts});
          //按钮  
          var deletedata =new Array();
          var adddata =new Array();
          var updata =new Array();
          var validateData=new Array();
          //var itemt="区域";
          var identity=0;
          var selectNode;
          
          model = new dojox.grid.data.Table(null, placedata);
		  var treeModel = new dijit.tree.ForestStoreModel({
  				store: popStore,
  				rootId: "root",
  				rootLabel: "",
  				childrenAttrs: ["children"]
  			});        
          var layout =[{type: 'dojox.GridRowView', width: '20px' },{
                       
                        cells: [
                                [
                                 { name: '选择', width: 3, styles: 'text-align: center;', editor: dojox.grid.editors.Bool },
                                 //{ name: 'no', width: 2, get: function(inRowIndex){ return inRowIndex+1;} },
                                 {name: '名称', width: 20,editor: dojox.grid.editors.Input },
                                 {name: '邮编', width: 10, editor: dojox.grid.editors.Input},
                                 {name: '备注', width: 20, editor: dojox.grid.editors.Input},
                                 {name: '类型', width: 10, field: 4,editor: dojox.grid.editors.Select,options: [ "区域", "省", "城市", "城区", "街道", "地址" ]}
                                ]
                              ]
                        }];
                        
          //初始查询结果列表
                queryModel = new dojox.grid.data.Table(null, querydata);
         var querylayout =[{type: 'dojox.GridRowView', width: '20px' },{
                       
                        cells: [
                                [
                                 { name: '选择', width: 3, styles: 'text-align: center;',editor: dojox.grid.editors.Bool },
                                 //{ name: 'no', width: 2, get: function(inRowIndex){ return inRowIndex+1;} },
                                 {name: '名称', width: 20},
                                 {name: '邮编', width: 10},
                                 {name: '备注', width: 20},
                                 {name: '类型', width: 10}
                                ]
                              ]
                        }];                 
                        
 	
          //保存列表
                   
          addRow = function(){
          	gridWidget.addRow([false,"","","","",0],gridWidget.model.getRowCount());
	         	gridWidget.updateRow();
	         } 
	         
    function call_funUpd() {
           var s = gridWidget.selection.getSelected();
            var url = "http://localhost:8080/logistics-ws/services/BasicManageService";
           
           for(var i=0;i<s.length;i++){
           var ii=s[i];
           //alert(i+":"+ii);
            var thisCell=gridWidget.model.data[ii];
          // alert(thisCell[5]+":"+thisCell[5]);
           //alert(thisCell[4]+":"+thisCell[4]);
          // alert("identity:"+identity);
            
             var padd = new SOAPClientParameters2();
            
             var placevo=new Object();
             placevo.id=thisCell[5];
             if(dojox.validate.isText(thisCell[1], {minlength: 1})){
              placevo.placeName=thisCell[1];
             }else{
             continue;
             }
              if(dojox.validate.isText(thisCell[2], {minlength: 1})){
             placevo.postCode=thisCell[2];}else{
             continue;
             }
             if(dojox.validate.isText(thisCell[4], {minlength: 1})){
             placevo.placeType=thisCell[4];
             }else{
               continue;
               }
              //if(dojox.validate.isText(thisCell[1], {minlength: 1})){
             placevo.parentPlaceId=identity; 
             /*}else{
             continue;
             }*/
             // if(dojox.validate.isText(thisCell[1], {minlength: 1})){
             placevo.trafficeGrade='1';
             /*}else{
             continue;
             }*/
              if(dojox.validate.isText(thisCell[3], {minlength: 1})){
             placevo.remark=thisCell[3];}else{
             continue;
             }
            
          if(thisCell[5]==0){//新增的记录
                   /*
                  Random rd = new Random();
                  flowInfo.wzFlowID = WZConstants.PREFIX_PLAN_FLOW + System.currentTimeMillis()+flowInfo.hashCode()+rd.nextInt();
                  */
                padd.add('WlPlaceVO',placevo);
                //padd.add('WlPlaceVO',{id:,parentPlaceId:1,placeName:thisCell[1],placeType:'area',postCode:thisCell[2],trafficeGrade:'1',remark:'1'});
                SOAPClient.invoke(url, "createPlace", padd, false,  function GetEnu_callBack(ul, soapResponse){
                if(placevo.placeType!='地址'){
                addTreeNode(selectNode,placevo.placeName,placevo.placeType,ul);
                }
                gridWidget.model.setDatum(ul,i,5);
                //gridWidget.updateRow();
                });
          }else{//修改的记录
                             
                padd.add('WlPlaceVO',placevo);
                //padd.add('WlPlaceVO',[{id:1,parentPlaceId:1,placeName:thisCell[1],placeType:'area',postCode:thisCell[2],trafficeGrade:'1',remark:'1'},{id:2,parentPlaceId:1,placeName:thisCell[1],placeType:'area',postCode:thisCell[2],trafficeGrade:'1',remark:'1'}]) ;
                SOAPClient.invoke(url, "updatePlace", padd, false,  function GetEnu_callBack(ul, soapResponse){
                //alert("upd=="+ul);
                if(placevo.placeType!='地址'){
                setTreeNode(placevo.id,placevo.placeName,placevo.placeType);
                }
                });
             }
		       //
          }
          
          //提交删除的记录？
              for(var i=0;i<deletedata.length;i++){
                   var pdel = new SOAPClientParameters();      
                   pdel.add('id',deletedata[i]);
                   //alert(deletedata.length+";"+deletedata[i]);
                //padd.add('WlPlaceVO',{id:,parentPlaceId:1,placeName:thisCell[1],placeType:'area',postCode:thisCell[2],trafficeGrade:'1',remark:'1'});
                SOAPClient.invoke(url, "deletePlaces", pdel, false,  function GetEnu_callBack(ul, soapResponse){
                 // alert("del=="+ul);
                  delTreeNode(deletedata[i]);
                });
              }
              gridWidget.updateRow();
              deletedata=new Array();
              
              //同步数据库，显示树                            
    }
          
          
          function removeSelectedRows(){
           var s = gridWidget.selection.getSelected();
           for(var i=0;i<s.length;i++){ 
             var ii=s[i];
             var thisCell=gridWidget.model.data[ii];
             if(thisCell[5]!=0){//要删除的记录
               deletedata.splice(deletedata.length,0,thisCell[5]);
             }
           }    
           gridWidget.removeSelectedRows();
           gridWidget.updateRow();
          
          }   
           
           //添加树节点
         function addTreeNode(pid,placeName,placeType,id){
               // add a treenode for FR
               //alert(pid);
                /*var chdata=new Array();
					chdata[0]= {label:placeName, item: {name: placeName,type:placeType ,eId:id}};
					pid._addChildren(chdata);
					pid.isFolder=true;
					pid.collapse();*/
               //var _tree=dijit.byId(pid);
               //var fr=_tree.getChildren()[1];
               var pInfo = {
                        					parent: pid.item,		
                        					attribute: "children"	
                        				};
               popStore.newItem({name: placeName,type:placeType ,eId:id}, pInfo);
              
         }  
         
         
         function delTreeNode(id){
               	var node = dijit.byId("tree")._itemNodeMap[id];
                popStore.deleteItem(node.item);//同时删除所有子节点
              }  
              
          function setTreeNode(id,placeName,placeType){
               	var node = dijit.byId("tree")._itemNodeMap[id];
               	//alert("placeName:"+placeName);
               	//alert("placeType:"+placeType);
                popStore.setValue(node.item,"placeName",placeName);         
                popStore.setValue(node.item,"placeType",placeType);      
                node.setLabelNode(placeName);
                 }  
           

 //-----------------------------------------------          
 		  var gridIncWlPathdata =  new Array();
          var queryIncWlPathdata =  new Array();
          var queryIncWlPathvo=new WlPathVOJs(); //
          var totalCountIncWlPath=0 ;
          var totalpageIncWlPath=0 ;
          var pagenumberIncWlPath=1;
          var pagesizeIncWlPath=10;     
		  var orderByIncWlPath='%';
          var gridIncWlPath=undefined;
          var modelIncWlPath = new dojox.grid.data.Table(null, gridIncWlPathdata);
		  var deletedatapath=new Array();
var editfieldpath =[{type: 'dojox.GridRowView', width: '20px' },{
    	 cells:  [[
				  { name: 'choise', width: 3,field:0, styles: 'text-align: center;', editor: dojox.grid.editors.Bool },//
				   { name: 'No.', width: 2, styles: 'text-align: center;', get: function(inRowIndex){ return inRowIndex+1;} },//
				   {name: 'pathName', field: 2,width: 10 , editor: mydojo.ValidationTextBox ,required:true ,maxLength:30,invalidMessage:'can not be empty'}
				,  {name: 'distance',field:3, width: 8,editor: dojox.grid.editors.Dijit, editorClass: "mydojo.NumberTextBox", constraint: {min:0,max:9999999,places:4 } }
				,  {name: 'loanStandard',field:4, width: 8,editor: dojox.grid.editors.Dijit, editorClass: "mydojo.NumberTextBox", constraint: {min:0,max:9999999,places:4 } }
				,  {name: 'time',field:5, width: 8,editor: dojox.grid.editors.Dijit, editorClass: "mydojo.NumberTextBox", constraint: {min:0,max:9999999,places:4 } }
				,  {name: 'startPlace', field: 6,width: 10,get: function(inRowIndex){ if(queryIncWlPathdata[inRowIndex][6]!=undefined){return queryIncWlPathdata[inRowIndex][6][2]+'<button dojoType="dijit.form.Button" onclick="selectPlace('+queryIncWlPathdata[inRowIndex][6][1]+','+inRowIndex+',6,event);"   iconClass="peoIcon">place</button>';}else{return '<button dojoType="dijit.form.Button" onclick="selectPlace(undefined,'+inRowIndex+',6,event);"   iconClass="peoIcon">place</button>';}} }
				,  {name: 'endPlace', field: 7,width: 10 ,get: function(inRowIndex){ if(queryIncWlPathdata[inRowIndex][7]!=undefined){return queryIncWlPathdata[inRowIndex][7][2]+'<button dojoType="dijit.form.Button" onclick="selectPlace('+queryIncWlPathdata[inRowIndex][7][1]+','+inRowIndex+',7,event);"   iconClass="peoIcon">place</button>';}else{return '<button dojoType="dijit.form.Button" onclick="selectPlace(undefined,'+inRowIndex+',7,event);"   iconClass="peoIcon">place</button>';}} }
				   ] ]
   }];
   
function getVOIncWlPath(queryIncWlPathvo,pagenumberIncWlPath,pagesizeIncWlPath,orderByIncWlPath){

      var pu = new SOAPClientParameters2();
	  pu.add('endPlaceID',queryIncWlPathvo) ;
      //pu.add('WlPathVO',queryIncWlPathvo) ;
      //pu.add('pageNumber',pagenumberIncWlPath) ;
	   // pu.add('pageSize',pagesizeIncWlPath) ;
	   // pu.add('orderBy',orderByIncWlPath) ;
      SOAPClient.invoke(url,"getPathvoByEndPlace", pu, false,  function GetEnu_callBack(ul, soapResponse){      
           queryIncWlPathdata=WlPathVOtoArray_fun(ul,false);
           //totalCountIncWlPath=ul[ul.length-1]["ns:id"]; 
           // totalpageIncWlPath=Math.ceil(new Number(totalCountIncWlPath)/pagesizeIncWlPath);
           //document.getElementById("rowCountIncWlPath").innerHTML=" "+pagenumberIncWlPath+" / "+totalpageIncWlPath+" / "+totalCountIncWlPath+" " ;
      }); 
      //queryIncWlPathdata.splice(queryIncWlPathdata.length-1,1);
      modelIncWlPath.setData(queryIncWlPathdata);
	  //if(totalpage>1){dijit.byId("but7").setDisabled(false);}else{dijit.byId("but7").setDisabled(true);}
	  /*var button7 = new dijit.form.myButton({label: "pagedown", onClick: downPageIncWlPath,id:"but7IncWlPath",iconClass:"downPageIcon" });
	  document.getElementById("but7IncWlPathDiv").appendChild(button7.domNode);
	  if(totalpageIncWlPath>1){dijit.byId("but7IncWlPath").setDisabled(false);}else{dijit.byId("but7IncWlPath").setDisabled(true);}*/
	  //dijit.byId("grid").updateRowCount(queryIncWlPathdata.length); 
 }

   
var querybuttonIncWlPath=function(){
              //var p = new SOAPClientParameters2();
              var d,n;
              var validstate=0;
              //queryIncWlPathvo.id=0 ;
              queryIncWlPathvo=new WlPathVOJs();
              if(querypathNameIncWlPath.getDisplayedValue()!="")queryIncWlPathvo.pathName=querypathNameIncWlPath.getDisplayedValue();//
              n=queryNumber_fun("distance");
              if(n==null){validstate=1;}else if(n.upSign!="%"){queryIncWlPathvo.distance=n;}  
              n=queryNumber_fun("loanStandard");
              if(n==null){validstate=1;}else if(n.upSign!="%"){queryIncWlPathvo.loanStandard=n;}  
              n=queryNumber_fun("time");
              if(n==null){validstate=1;}else if(n.upSign!="%"){queryIncWlPathvo.time=n;}  
        if(validstate==0){
              pagenumberIncWlPath=1;
              getVOIncWlPath(queryIncWlPathvo,pagenumberIncWlPath,pagesizeIncWlPath,orderByIncWlPath); 
              //if(totalpageIncWlPath>1){dijit.byId("but7IncWlPath").setDisabled(false);}else{dijit.byId("but7IncWlPath").setDisabled(true);} 
             }      
       }


 

 
var querydisIncWlPath = function(){   querydisplay("queryDivIncWlPath");   }
var allpageIncWlPath =function(){
      pagenumberIncWlPath=0;pagesizeIncWlPath=0;
      getVOIncWlPath(queryvoIncWlPath,pagenumberIncWlPath,pagesizeIncWlPath,orderByIncWlPath);
 }
var  pagesizeChangeIncWlPath=function(mylabel){
    pagesizeIncWlPath=mylabel;
    getVOIncWlPath(queryvoIncWlPath,pagenumberIncWlPath,pagesizeIncWlPath,orderByIncWlPath);
 }           
var upPageIncWlPath= function(){
     
     var pagenumbers=new Number(pagenumberIncWlPath)-1;
     pagenumberIncWlPath=pagenumbers.toString();
     getVOIncWlPath(queryvoIncWlPath,pagenumberIncWlPath,pagesizeIncWlPath,orderByIncWlPath);
        //dijit.byId("grid").updateRowCount(querydata.length);      //dijit.byId("grid").update();
  			if(pagenumber==1){
        dijit.byId("but6IncWlPath").setDisabled(true);
        }
        var totalpageIncWlPath=Math.ceil(new Number(totalCountIncWlPath)/pagesizeIncWlPath);
        if(totalpageIncWlPath>pagenumberIncWlPath){
        dijit.byId("but7IncWlPath").setDisabled(false);
        }
        var totalpageIncWlPath=Math.ceil(new Number(totalCountIncWlPath)/pagesizeIncWlPath);
        document.getElementById("rowCountIncWlPath").innerHTML=" "+pagenumberIncWlPath+" / "+totalpageIncWlPath+" / "+totalCountIncWlPath+" " ; 
}
var downPageIncWlPath =function(){

       var pagenumbers=new Number(pagenumberIncWlPath)+1;
       pagenumberIncWlPath=pagenumbers.toString();
      getVOIncWlPath(queryvoIncWlPath,pagenumberIncWlPath,pagesizeIncWlPath,orderByIncWlPath);  
      //dijit.byId("grid").updateRowCount(querydata.length);      //dijit.byId("grid").update();
			var totalpageIncWlPath=Math.ceil(new Number(totalCountIncWlPath)/pagesizeIncWlPath);
			if(totalpageIncWlPath==pagenumberIncWlPath){
			dijit.byId("but7IncWlPath").setDisabled(true);
      }
      if(pagenumber>1){
      dijit.byId("but6IncWlPath").setDisabled(false);
      }
      var totalpageIncWlPath=Math.ceil(new Number(totalCountIncWlPath)/pagesizeIncWlPath);
      document.getElementById("rowCountIncWlPath").innerHTML=" "+pagenumberIncWlPath+" / "+totalpageIncWlPath+" / "+totalCountIncWlPath+" " ; 
      
}

var call_funUpdpath =function() {
       //var s = gridIncWlPath.selection.getSelected();
       //var  d=new DateTimeQuery();
       //var n=new NumberQuery();
       var sall=gridIncWlPath.model.data;
       for(var i=0;i<sall.length;i++){
       if(sall[i][0]==true){
         var passAll=0;
         var thisCell=sall[i];
         var padd = new SOAPClientParameters2();
         var vobject=new WlPathVOJs();
         vobject.id=thisCell[1];
              if(dojox.validate.isText(thisCell[2], {minlength: 1})){vobject.pathName=thisCell[2];
             }else{gridIncWlPath.getCell(2).getNode(i).innerHTML="<span style={color:red;line-height:16px}>can not be null</span>"; passAll=1;}//not null
 
             if(dojox.validate.isInRange(thisCell[3],{max:9999999, min:0})){
              var  n=new NumberQuery(); n.upNumber=thisCell[3];vobject.distance=n;
             }else{gridIncWlPath.getCell(3).getNode(i).innerHTML="<span style={color:red;line-height:16px}> not be double</span>";passAll=1;}//double

             if(dojox.validate.isInRange(thisCell[4],{max:9999999, min:0})){
              var  n=new NumberQuery(); n.upNumber=thisCell[4];vobject.loanStandard=n;
             }else{gridIncWlPath.getCell(4).getNode(i).innerHTML="<span style={color:red;line-height:16px}> not be double</span>";passAll=1;}//double

             if(dojox.validate.isInRange(thisCell[5],{max:9999999, min:0})){
              var  n=new NumberQuery(); n.upNumber=thisCell[5];vobject.time=n;
             }else{gridIncWlPath.getCell(5).getNode(i).innerHTML="<span style={color:red;line-height:16px}> not be double</span>";passAll=1;}//double
			if(thisCell[6][1]!=undefined){
			var splace=new WlPlaceVOJs();	splace.id=thisCell[6][1];
			vobject.startPlaceID=splace;}
			if(thisCell[7][1]!=undefined){
			var eplace=new WlPlaceVOJs();	eplace.id=thisCell[7][1];
			vobject.endPlaceID=eplace;}
	   if(passAll==0){
             if(thisCell[1]==0){//create new row
                padd.add('WlPathVO',vobject);
                SOAPClient.invoke(url, "createPath", padd, false,  function GetEnu_callBack(ul, soapResponse){
                gridIncWlPath.model.setDatum(ul,i,1);
                });
	         }else{//modify row
                padd.add('WlPathVO',vobject);
                SOAPClient.invoke(url, "updatePath", padd, false,  function GetEnu_callBack(ul, soapResponse){
                });
	         }
        } }}//for
//submit delete
          for(var i=0;i<deletedatapath.length;i++){
               var pdel = new SOAPClientParameters();      
               pdel.add('id',deletedatapath[i]);
               SOAPClient.invoke(url, "deletePath", pdel, false,  function GetEnu_callBack(ul, soapResponse){
	             
	           });
          }
          deletedatapath=new Array();
          dojo.byId("rowCountIncWlPath").innerHTML = 'saved'; 
//submit delete end          
 }

var removeSelectedRowsGridpath= function(){
       //var s = gridIncWlPath.selection.getSelected();
       var s= new Array();
       var sall=gridIncWlPath.model.data;
       for(var i=0;i<sall.length;i++){
       if(sall[i][0]==true){
          s.push(i);
          var thisCell=sall[i];
          if(thisCell[1]!=0){//the row which will be deleted
            deletedatapath.splice(deletedatapath.length,0,thisCell[1]);
       }}}
       gridIncWlPath.model.remove(s);//gridIncWlPath.removeSelectedRows();
 }
        
var addRowpath = function(){
          	gridIncWlPath.addRow([false,0,"","",""],gridIncWlPath.model.getRowCount());
	        } 


          
                    
        
           
 function init(){
         
           dojo.connect(gridWidget, "doStartEdit", function(inCell, inRowIndex){
           
            });  
            //单击查询列表里的记录，可选中树中的相应节点
          dojo.connect(queryGrid, "onRowClick", function(e){
                alert(e.rowIndex);
            });  
        
						 
 
 
	 //添加区域结点
		
		var pl = new SOAPClientParameters();
		//pl.add('eType','区域') ;
		pl.add('type','区域') ;
		SOAPClient.invoke(url, "getPlacevoByPlaceType", pl, false,  function GetEnu_callBack(ul, soapResponse){
		  var pInfo = {
									parent: null,		
									attribute: "children"	
								};
			for(var i = 0; i < ul.length; i++){		
						 var ulo=ul[i];
						 popStore.newItem({name: ulo["ns:placeName"],type:ulo["ns:placeType"] ,eId:ulo["ns:id"],haveChild:"1"}, pInfo);//haveChild=0初始，1有子结点，2无子结点
						 var items = new Array();
						  items[0] = false;
						  items[1] = ulo["ns:placeName"];
						  items[2] = ulo["ns:postCode"];
						  items[3] = ulo["ns:remark"];
						  items[5] = ulo["ns:id"];
						  items[4] = ulo["ns:placeType"];
						  placedata[i]=items;
					}
			model.setData(placedata);    
			//dojo.contentBox(gridWidget.domNode, {w: 400, h: 400});
			//gridWidget.update();     
	   });
			   
			  
	//添加省份结点
		var chitem;
		var chdata =new Array();
		var _tree=dijit.byId("tree");
		var childrenArray1=_tree.rootNode.getChildren();
		
		for (var i=0; i<childrenArray1.length; i++){//begin	
			var p2 = new SOAPClientParameters();
			
			var chNode =childrenArray1[i];
			chitem=chNode.item;
		var p2Info = {	parent: chitem,		
								attribute: "children"	
						   };
		
			p2.add('parentPlaceId',chitem.eId) ;
			SOAPClient.invoke(url, "getPlacevoByParentPlaceId", p2 ,false,  function GetEnu_callBack(ul1, soapResponse){  
				if(ul1!=null){
					for(var ii = 0; ii < ul1.length; ii++){	   
									  var ulo=ul1[ii];
									 var newItemCity=	popStore.newItem({name: ulo["ns:placeName"],type:ulo["ns:placeType"] ,eId:ulo["ns:id"],haveChild:"0"}, p2Info);
										
						}
					chNode._updateItemClasses(chNode.item);	
				}	
					
			   });
			  
			
		}//end
                
            _tree._expandNode(_tree.rootNode);    
               
           
                 
                 
                 //添加城市、城区结点
             dojo.connect(dijit.byId("tree"), "_onExpandoClick", function(message){
                       // _expandNode
                       var node = message.node;
                       var ch2node=node.getChildren();
                       // alert("erwer==="+ch2node.length);
                       for (var i=0; i<ch2node.length; i++){	//BEGIN
                       //alert(ch2node[i].getChildren().length);
					   if(ch2node[i].item.haveChild=='0'){
                       //if(ch2node[i].item.haveChild=='0'){
                         var ch2item =ch2node[i].item;
                        
                         var p3 = new SOAPClientParameters();
                         var p3Info = {
                                        parent: ch2item,		
                                        attribute: "children"	
                                       };
                        p3.add('parentPlaceId',ch2item["eId"]) ;
						var havechilds=0;
                        SOAPClient.invoke(url, "getPlacevoByParentPlaceId", p3 ,false,  function GetEnu_callBack(ul2, soapResponse){  
                            
                            for(var j = 0; j < ul2.length; j++){
                                var ulo=ul2[j];		
                                 if(ulo["ns:placeType"]!='地址'){
								 havechilds=1;
								popStore.newItem( {name: ulo["ns:placeName"],type:ulo["ns:placeType"] ,eId:ulo["ns:id"],haveChild:"0"}, p3Info);
                         }}
							 if(havechilds==1){
								 ch2node[i]._updateItemClasses(ch2node[i].item);
								 popStore.setValue(ch2item,"haveChild","1"); 
							 }else{popStore.setValue(ch2item,"haveChild","2");   }   
						 });
                         }
                      
                      }//END
             	 
            });
 
       
           //查询列表----begin
            dojo.connect(_tree, "onClick", function(item,node){
                    placedata = new Array();
                    selectNode=node;
                    identity = _tree.store.getIdentity(item);
                    var url0 = "http://localhost:8080/logistics-ws/services/BasicManageService";
                    var p0 = new SOAPClientParameters();
                    p0.add('parentPlaceId',item["eId"]) ;
                    //titles=item["type"];
                SOAPClient.invoke(url0, "getPlacevoByParentPlaceId", p0, false,  function GetEnu_callBack(ul, soapResponse){   
                   
                     for(var i = 0; i < ul.length; i++){		
                      var items = new Array();
                      var ulo=ul[i];
                        items[0] = false;
                        items[1] = ulo["ns:placeName"];
                        items[2] = ulo["ns:postCode"];
                        items[3] = ulo["ns:remark"];
                        items[5] = ulo["ns:id"];
                        items[4] = ulo["ns:placeType"];
                        placedata[i]=items;
                    }                
                });       
                model.setData(placedata);
                gridWidget.selection.clear();
                
                
                
                var titles=node.item["name"];
                var parentNodes=node;
              
                while(parentNodes.getParent()!= null&& parentNodes.getParent()["id"]!="tree"){
                      parentNodes=parentNodes.getParent();
                      titles=parentNodes.item["name"]+' '+titles;
                };
              	dojo.byId("placetitle").innerHTML = titles +"";
                deletedata =new Array();                       
                                     
                                     });  
              
            	
            
            
            
            
           //查询列表----end
           dojo.connect(gridWidget.model, "onSelected", function(e){
                    //alert("c3="+e);
                  
            });  
			
			//init-----------
//var initTab =function(){
dojo.connect(dijit.byId("mainTabContainer"),'selectChild',function(){
if(dijit.byId("pathTab").selected==true){
if(selectNode!=undefined){var endPlace=selectNode.item["eId"];
}else{var endPlace=0;}
//if(selectNode!=)
 /*var pathendplace=new WlPlaceVOJs();
 pathendplace.id=selectNode.item["eId"];
 queryIncWlPathvo.endPlace=pathendplace;*/
 getVOIncWlPath(endPlace,pagenumberIncWlPath,pagesizeIncWlPath,orderByIncWlPath); 
      //querydataInc.splice(querydataInc.length-1,1);
	  if(gridIncWlPath==undefined){
	  //alert(queryIncWlPathdata);
	  //modelIncWlPath = new dojox.grid.data.Table(null, queryIncWlPathdata);
				 gridIncWlPath = new dojox.Grid({
					title: "",
					id: "gridIncWlPath",
					jsId: "gridIncWlPath",
					structure: editfieldpath,
					rowCount:queryIncWlPathdata.length,
					model:modelIncWlPath,
					singleClickEdit:true
				}, dojo.byId("gridIncWlPath"));
				//dojo.contentBox(gridIncWlPath.domNode, {w: 400, h: 400});
			}//else{ gridIncWlPath.model.setData(queryIncWlPathdata); } 
	 //if(totalpageIncWlPath>1){dijit.byId("but7IncWlPath").setDisabled(false);}else{dijit.byId("but7IncWlPath").setDisabled(true);}	
	 }
});
        
           }//END INIT
            
           dojo.addOnLoad(init);
           

          //查询按钮
          
          
          function querybutton(){
          
              var url = "http://localhost:8080/logistics-ws/services/BasicManageService";
              var p = new SOAPClientParameters();
              alert(queryname.getDisplayedValue()+querypostcode.getDisplayedValue()+querytype.getDisplayedValue()+queryremark.getDisplayedValue());
              p.add('placeName','%'+queryname.getDisplayedValue()+'%') ;
              p.add('postCode','%'+querypostcode.getDisplayedValue()+'%') ;
              p.add('placeType','%'+querytype.getDisplayedValue()+'%') ;
              p.add('remark','%'+queryremark.getDisplayedValue()+'%') ;
                   
                SOAPClient.invoke(url, "getPlaceVO", p, false,  function GetEnu_callBack(ul, soapResponse){   
                     querydata=new Array();        
                     for(var i = 0; i < ul.length; i++){		
                      var items = new Array();
                      var ulo=ul[i];
                        items[0] = false;
                        items[1] = ulo["ns:placeName"];
                        items[2] = ulo["ns:postCode"];
                        items[3] = ulo["ns:remark"];
                        items[4] = ulo["ns:placeType"];
                        items[5] = ulo["ns:id"];
                      querydata[i]=items;
                    }                
                });       
                queryModel.setData(querydata); 
          //dojo.contentBox(queryGrid.domNode, {w: 800, h: 800});
          //queryGrid.domNode.style.width =400;
			    //queryGrid.domNode.style.height =400;
          //queryGrid.update();
          }
           
          function  autoaddbutton(){
          
          
          }
//pop select place 
	  var placeNo;
		  var selectplaceIDs;
		  var oldplaceFloat;
		  var selectplaceInRow;
		  var ifMultplace=0;
function selectPlace(myID,inrow,placeColNo,e){
var floath=e.screenY-window.screen.availHeight+document.body.clientHeight+30;
if(floath+255>document.body.clientHeight)floath=floath-255;
var floatw=e.screenX;
if(e.screenX+505>document.body.clientWidth)floatw=floatw-500;
						selectplaceInRow=inrow;
						placeNo=placeColNo;
						selectplaceIDs=myID;
						//ifMult=ifMults;
						
						oldplaceFloat = dijit.byId("selectPlaceFloat_1");
						if(oldplaceFloat==undefined){
							var div = dojo.doc.createElement('div');
							dojo.body().appendChild(div);
							var fp = new dojox.layout.FloatingPane({id:"selectPlaceFloat_1",title:"选择地点",
								maxable: true,closable: true,resizable: true ,dockable:true,
								href:"../common/selectPlaceFloat.html"},div);
							dojo.style(fp.domNode,{
								width:"500px",height:"255px",top:floath, left:floatw,position:"absolute",zIndex:"980"});
							oldplaceFloat=fp;
							fp.startup();
							fp.show();
							
						}else{
						    dojo.style(oldplaceFloat.domNode,{width:"500px",height:"255px",
								top:floath, left:floatw,
								position:"absolute",zIndex:"980"});
							oldplaceFloat.show();
							//alert(gridIncWlPlacedata);
							//gridIncWlPlace.model.setData(gridIncWlPlacedata);
						}
}
function selectIncWlPlaceFun(rep){
	queryIncWlPathdata[selectplaceInRow][placeNo]=rep;
	gridIncWlPath.updateRow(selectplaceInRow);		
}	             
</script>
</head>
<body class="tundra">
    <div id="bc" style="width:100%; height:100%;" dojoType="dijit.layout.BorderContainer">
	    <div dojoType="dojox.layout.ExpandoPane" splitter="true" duration="125" region="left" title="Left Section" id="treePane" maxWidth="275" style="width: 275px; background: #fafafa;">
			<div id="tree" showRoot="true" class="container" persist="false" dojoType="dijit.Tree"  store="popStore" labelAttr="name"  childrenAttr="children"  model="treeModel" ></div>		
		</div>   
		<div id="mainTabContainer" dojoType="dijit.layout.TabContainer"  region="center"  >
	        
	      <div id="queryDiv" dojoType="dijit.layout.ContentPane" title="查询"  >
	      <table align="center" width=100% >
	      <tr><td>请输入查询条件：</td><td></td></tr>
	          <tr><td>名称：<input type="text" jsId="queryname"   dojoType="dijit.form.TextBox"  /></td>
	      
	         <td> 邮编：<input type="text" jsId="querypostcode"    dojoType="dijit.form.ValidationTextBox"  regExp="\d{0,6}"     invalidMessage="邮编应为不超过六位的阿拉伯数字"></td>
	          </tr><tr><td>备注：<input type="text" jsId="queryremark"   dojoType="dijit.form.TextBox"  /></td>
	          <td>类型：<select dojoType="dijit.form.FilteringSelect"  jsId="querytype" autocomplete="false" >
	                <option value=""></option>
	                <option value="区域">区域</option>
	                <option value="省" >省</option>
	                <option value="城市" >城市</option>
	                <option value="城区" >城区</option>
	                <option value="街道" >街道</option>
	                <option value="地址" >地址</option>
	          </select></td></tr>
	          </table>
	          <div align="center">
	          <button dojoType="dijit.form.Button" onclick="querybutton()"> 查询 </button>&nbsp;&nbsp;&nbsp;
	          <button dojoType="dijit.form.Button" onclick="autoaddbutton()">智能添加</button>  
	          </div>  
	           <p><p><p>
	          <div id="queryGrid" dojoType="dojox.Grid" jsId="queryGrid" style="{width:100%;height:630px}"	model="queryModel" structure="querylayout"  >
	           
	           
	           </div>
	      </div>
	      
	    <div id="LittleRed" dojoType="dijit.layout.ContentPane" title="地点" style="width: 100%; height:100%" selected="true"   onLoad="placeonload"  onDownloadStart="onDownloadStartl">
	        <div class="titleclass" id="placetitle"></div>
			<div align="right">
				 &nbsp;&nbsp;&nbsp;
					 <button dojoType="dijit.form.Button" onclick="addRow();" iconClass="addIcon" >add</button>
					 <button dojoType="dijit.form.Button" onclick="removeSelectedRows();" iconClass="delIcon" >delete</button>
					 <button dojoType="dijit.form.Button" id="but3" jsId="but3" onclick="call_funUpd();"  iconClass="saveIcon">save</button>
					 <!--button dojoType="dijit.form.Button" onclick="querydis();" iconClass="queryIcon" >query</button-->
				  
			</div>    
	        <div id="gridWidget"  dojoType="dojox.Grid"  style="{width:100%;height:660px}"	jsId="gridWidget"	model="model" structure="Layout" singleClickEdit="true"  ></div>
	        <div align="right" ><span id="rowCount"></span>
			        <button dojoType="dijit.form.myButton" onclick="upPage();"  id="but6" disabled='true' jsId="but6" iconClass="upPageIcon" >pageup</button><!--span dojoType="dijit.Tooltip" connectId="but6">pageup</span-->
			        <button dojoType="dijit.form.myButton" onclick="downPage();" id="but7" disabled='true' jsId="but7" iconClass="downPageIcon" >pagedown</button><!--span dojoType="dijit.Tooltip" connectId="but7">pagedown</span-->
			        <div  dojoType="dijit.form.myDropDownButton" iconClass="pageIcon" ><span>pageNumber</span>
			  			  <div dojoType="dijit.Menu">
							  <div dojoType="dijit.MenuItem" label="10"  iconClass="toPageIcon"		onClick="pageSizeChange(this.label);"></div>
							  <div dojoType="dijit.MenuItem"  label="30" iconClass="toPageIcon"		onClick="pageSizeChange(this.label);"></div>
					      <div dojoType="dijit.MenuItem"  label="50" iconClass="toPageIcon"		onClick="pageSizeChange(this.label);"></div>
								<div dojoType="dijit.MenuItem"  label="100" iconClass="toPageIcon"	onClick="pageSizeChange(this.label);"></div>
								<div dojoType="dijit.MenuItem"  label="noPage" iconClass="noPageIcon"	onClick="allpage();"></div>
					      </div><!--span dojoType="dijit.Tooltip" connectId="668"></span href="pathCrudTab.html" -->
			        </div>
					<div  dojoType="dijit.form.myDropDownButton" iconClass="pageStyleIcon"><span>pageStyle</span>
					<div dojoType="dijit.Menu">
					 <div dojoType="dijit.MenuItem"  iconClass="rowIcon"		label="row"	onClick="pageStyle(this.label);"></div>
					 <div dojoType="dijit.MenuItem"  iconClass="colIcon"		label="col"	onClick="pageStyle(this.label);"></div>
				    </div></div>
				</div> 
	      </div>
	      
	    <div id="pathTab" dojoType="dijit.layout.ContentPane"  title="路线" closable="false" preload="true">
	        <div id="queryDivIncWlPath" style="margin-right: 0px;  height: 460px; display:none;" >
              <table align="center" width="100%" class="queryTable"  >
                <tr ><td align="center" style="{width:11%}">Please input criterial:</td>
                <td style="{width:22%}" ></td>
                <td style="{width:11%}"></td>
                <td style="{width:6%}" ></td>
                <td style="{width:11%}" ></td>
                <td style="{width:6%}" ></td>
                <td style="{width:11%}"></td>
                <td style="{width:22%}"></td></tr> 
                <tr ><td align="center" style="{width:11%}"></td>
                <td style="{width:22%}" ></td>
                <td style="{width:11%}"></td>
                <td style="{width:6%}" ></td>
                <td style="{width:11%}" ></td>
                <td style="{width:6%}" ></td>
                <td style="{width:11%}"></td>
                <td style="{width:22%}"></td></tr>  
                <tr>
                    <td align="right"  >pathName:</td>
                    <td align="left"  ><input type="text" class="editerInput"  id="querypathNameIncWlPath"  jsId="querypathNameIncWlPath"   dojoType="dijit.form.TextBox"  /></td>
                    <td align="right"  >distance:</td>
                    <td align="left" colspan="3" ><span id="querydistanceIncWlPathImg0"  ><input type="text" class="editerNumber" jsId="querydistanceIncWlPath"  id="querydistanceIncWlPath"  dojoType="mydojo.NumberTextBox"  /></span>
                        <span id="querydistanceIncWlPathImg1"  style="{display:none}" ><input type="text" class="editerNumberSmall" jsId="querydistanceIncWlPath1"  id="querydistanceIncWlPath1"  dojoType="mydojo.NumberTextBox"  /></span>
                        <span hidefocus="true" style="{display:none}" onclick="selectSign(this);" id="querydistanceIncWlPathImgup">></span>
                        <img src="../image/start.gif" onclick="queryType(this);" id="querydistanceIncWlPathImg" height="15" width="20" border="0">
                        <span hidefocus="false"  style="{display:none}" onclick="selectSign(this);" id="querydistanceIncWlPathImgdown" >></span>
                        <span id="querydistanceIncWlPathImg2div" style="{display:none}"> <input type="text" class="editerNumberSmall"  jsId="querydistanceIncWlPath2"  id="querydistanceIncWlPath2"  dojoType="mydojo.NumberTextBox"  /></span>
                    </td>  
                    <td align="right"  >loanStandard:</td>
                    <td align="left"  ><span id="queryloanStandardIncWlPathImg0"  ><input type="text" class="editerNumber" jsId="queryloanStandardIncWlPath"  id="queryloanStandardIncWlPath"  dojoType="mydojo.NumberTextBox"  /></span>
                        <span id="queryloanStandardIncWlPathImg1"  style="{display:none}" ><input type="text" class="editerNumberSmall" jsId="queryloanStandardIncWlPath1"  id="queryloanStandardIncWlPath1"  dojoType="mydojo.NumberTextBox"  /></span>
                        <span hidefocus="true" style="{display:none}" onclick="selectSign(this);" id="queryloanStandardIncWlPathImgup">></span>
                        <img src="../image/start.gif" onclick="queryType(this);" id="queryloanStandardIncWlPathImg" height="15" width="20" border="0">
                        <span hidefocus="false"  style="{display:none}" onclick="selectSign(this);" id="queryloanStandardIncWlPathImgdown" >></span>
                        <span id="queryloanStandardIncWlPathImg2div" style="{display:none}"> <input type="text" class="editerNumberSmall"  jsId="queryloanStandardIncWlPath2"  id="queryloanStandardIncWlPath2"  dojoType="mydojo.NumberTextBox"  /></span>
                    </td>  
              </tr>
                <tr>
                    <td align="right"  >time:</td>
                    <td align="left"  ><span id="querytimeIncWlPathImg0"  ><input type="text" class="editerNumber"   jsId="querytimeIncWlPath"  id="querytimeIncWlPath"  dojoType="mydojo.NumberTextBox"  /></span>
                        <span id="querytimeIncWlPathImg1" style="{display:none}" ><input type="text"  class="editerNumberSmall" jsId="querytimeIncWlPath1"  id="querytimeIncWlPath1"  dojoType="mydojo.NumberTextBox"  /></span>
                        <span hidefocus="true" style="{display:none}" onclick="selectSign(this);" id="querytimeIncWlPathImgup">></span>
                        <img src="../image/start.gif" onclick="queryType(this);" id="querytimeIncWlPathImg" height="15" width="20" border="0">
                        <span hidefocus="false"  style="{display:none}" onclick="selectSign(this);" id="querytimeIncWlPathImgdown" >></span>
                        <span id="querytimeIncWlPathImg2div" style="{display:none}"> <input type="text"  class="editerNumberSmall"  jsId="querytimeIncWlPath2"  id="querytimeIncWlPath2"  dojoType="mydojo.NumberTextBox"  /></span>
                    </td>
	
			  <tr align="center"><td></td>
			   <td colspan="2"><a onclick="querybuttonIncWlPath();"><img src="../image/332.gif" height="20" width="20" border="0">OK</a></td>
			   <td colspan="3"></td><td colspan="2"></td></tr>
			 </table>
			 </div>
				<div align="right">
					 &nbsp;&nbsp;&nbsp;
						 <button dojoType="dijit.form.Button" onclick="addRowpath();" iconClass="addIcon" >add</button>
						 <button dojoType="dijit.form.Button" onclick="removeSelectedRowsGridpath();" iconClass="delIcon" >delete</button>
						 <button dojoType="dijit.form.Button" id="but3path" jsId="but3path" onclick="call_funUpdpath();"  iconClass="saveIcon">save</button>
						 <button dojoType="dijit.form.Button" onclick="querydisIncWlPath();" iconClass="queryIcon" >query</button>
			  </div>  
			   
			<div style="{height:90%;width:100%}"  >
				 <!--div id="gridIncWlPath"  dojoType="dojox.Grid" autoWidth="false"  jsId="gridIncWlPath"	model="modelIncWlPath"  structure="editfieldpath" singleClickEdit="true" ></div-->
				 <div id="gridIncWlPath" ></div>
		  </div>      
		  <div align="right" ><span id="rowCountIncWlPath"></span>
			<button dojoType="dijit.form.myButton" onclick="upPageIncWlPath();"  id="but6IncWlPath" disabled='false' jsId="but6IncWlPath" iconClass="upPageIcon" >pageup</button><!--span dojoType="dijit.Tooltip" connectId="but6">pageup</span-->
			<button dojoType="dijit.form.myButton" onclick="downPageIncWlPath();" id="but7IncWlPath" disabled='false' jsId="but7IncWlPath" iconClass="downPageIcon" >pagedown</button><!--span dojoType="dijit.Tooltip" connectId="but7">pagedown</span-->
			<!--span id="but7IncWlPathDiv" ></span-->
			<div  dojoType="dijit.form.myDropDownButton" iconClass="pageIcon" ><span>pageNumber</span>
				  <div dojoType="dijit.Menu">
					  <div dojoType="dijit.MenuItem" label="10"  iconClass="toPageIcon"		onClick="pageSizeChangeIncWlPath(this.label);"></div>
					  <div dojoType="dijit.MenuItem"  label="30" iconClass="toPageIcon"		onClick="pageSizeChangeIncWlPath(this.label);"></div>
				  <div dojoType="dijit.MenuItem"  label="50" iconClass="toPageIcon"		onClick="pageSizeChangeIncWlPath(this.label);"></div>
						<div dojoType="dijit.MenuItem"  label="100" iconClass="toPageIcon"	onClick="pageSizeChangeIncWlPath(this.label);"></div>
						<div dojoType="dijit.MenuItem"  label="noPage" iconClass="noPageIcon"	onClick="allpageIncWlPath();"></div>
				  </div><!--span dojoType="dijit.Tooltip" connectId="668"></span-->
			</div>
				<div dojoType="dijit.form.myDropDownButton" iconClass="pageStyleIcon"><span>pageStyle</span>
				   <div dojoType="dijit.Menu">
					 <div dojoType="dijit.MenuItem"  iconClass="rowIcon"		label="row"	onClick="pageStyleIncWlPath(this.label);"></div>
					 <div dojoType="dijit.MenuItem"  iconClass="colIcon"		label="col"	onClick="pageStyleIncWlPath(this.label);"></div>
				</div></div>
		 </div>

	    </div>
	      
		</div>

                       
	</div>
</body></html>
